<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>列表</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="../../css/oksub.css">
	<script type="text/javascript" src="../../lib/loading/okLoading.js"></script>
</head>
<body>
<div class="ok-body">
	<!--模糊搜索区域-->
	<div class="layui-row">
		<form class="layui-form layui-col-md12 ok-search">
			<div class="layui-input-inline">
                <label class="layui-form-label">预约日期</label>
                <div class="layui-input-block">
                    <input class="layui-input date" placeholder="预约日期" autocomplete="off" name="date">
                </div>
            </div>
			<div class="layui-input-inline">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-block">
                    <input type="radio" name="status" value="" title="所有" checked>
                    <input type="radio" name="status" value="1" title="待签到">
					<input type="radio" name="status" value="3" title="已完成">
                    <input type="radio" name="status" value="4" title="已取消">
                	<input type="radio" name="status" value="5" title="临时闭馆">
                </div>
            </div>
			<button class="layui-btn" lay-submit="" lay-filter="search">
				<i class="layui-icon layui-icon-search"></i>
			</button>
		</form>
	</div>
	<!--数据表格-->
	<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
</div>
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
	layui.use(["element", "table", "form", "okLayer", "okUtils", "okMock", 'laydate'], function () {
		let $ = layui.jquery;
		let table = layui.table;
		let form = layui.form;
		let okMock = layui.okMock;
		let okLayer = layui.okLayer;
		let okUtils = layui.okUtils;
		let laydate = layui.laydate;

		//关闭loading
		okLoading.close();

		//初始化日期选择器
        laydate.render({elem: ".date", type: "date", range: '~'});

		let theTable = table.render({
			elem: "#tableId",
			url: okMock.api.reservation_record.personal_list,
			limit: 10,
			page: true,
			toolbar: "#toolbarTpl",
			headers: { token: okUtils.get_token() },
			response: {
                statusCode: HTTP_OK	//返回的状态码，默认是0
            },
			cols: [[
				{field: "LAY_TABLE_INDEX",title: "序号",width: 60,align: "center",templet: '#zizeng'},
				{field: "date", title: "预约日期", width: 120},
				{field: "time", title: "预约时间段", width: 180},
				{field: "user_name", title: "预约人", width: 100},
				{field: "num", title: "预约人数", width: 100},
				{field: "status_name", title: "状态", width: 90},
				{title: "操作", width: 120, align: "center", templet: "#operationTpl",fixed: "right",}
			]],
			done: function (res, curr, count) {}
		});
		//把详情按钮放到最前面
		$("#operationTpl").prepend(
			'<a href="javascript:" title="详情" lay-event="detail"><i class="ok-icon">&#xe7c4;</i></a>'
		);

		//监听搜索按钮点击事件
		form.on("submit(search)", function (data) {
			//重载表格，并传递搜索条件
			theTable.reload({
				where: data.field,
				page: {curr: 1}
			});
			return false;
		});

		table.on("tool(tableFilter)", function (obj) {
			let data = obj.data;
			switch (obj.event) {
				case "detail":
					detail(data.id);
					break;
			}
		});

		function detail(id) {
			okLayer.open("详情", "personal_detail.html?id=" + id, "90%", "90%", null, function () {})
		}
		
	})
</script>
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl"></script>

<script type="text/html" id="operationTpl"></script>

<!-- 排序+1 -->
<script type="text/html" id="zizeng">
    {{d.LAY_TABLE_INDEX + 1}}
</script>
</body>
</html>
